6
תגובות
להוסיף בדיקות לקוד
פתח
phpon
,
יש לי את הקוד הבא:
ואני אמור להכניס עליו את
והנה הHTML
<html>
<head>
<title>my order!</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order processed at ".date('H:i, jS F Y')."</p>";
echo '<p>Your order is as follows: </p>';
echo $tireqty = $_POST['tireqty'].' tires<br />';
echo $oilqty = $_POST['oilqty'].' bottels of oil<br />';
echo $sparkqty = $_POST['sparkqty'].' spark plugs<br />';
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo "Items ordered: ".$totalqty."<br />";
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
echo "Subtotal: $".number_format($totalamount,2)."<br />";
$taxrate = 0.10; //local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
echo "Total including tax: $".number_format($totalamount,2)."<br />";
?>
</body>
</html>
<head>
<title>my order!</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order processed at ".date('H:i, jS F Y')."</p>";
echo '<p>Your order is as follows: </p>';
echo $tireqty = $_POST['tireqty'].' tires<br />';
echo $oilqty = $_POST['oilqty'].' bottels of oil<br />';
echo $sparkqty = $_POST['sparkqty'].' spark plugs<br />';
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo "Items ordered: ".$totalqty."<br />";
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
echo "Subtotal: $".number_format($totalamount,2)."<br />";
$taxrate = 0.10; //local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
echo "Total including tax: $".number_format($totalamount,2)."<br />";
?>
</body>
</html>
ואני אמור להכניס עליו את
echo ‘isset($tireqty): ‘.isset($tireqty).’<br />’;
echo ‘isset($nothere): ‘.isset($nothere).’<br />’;
echo ‘empty($tireqty): ‘.empty($tireqty).’<br />’;
echo ‘empty($nothere): ‘.empty($nothere).’<br />’;
echo ‘isset($nothere): ‘.isset($nothere).’<br />’;
echo ‘empty($tireqty): ‘.empty($tireqty).’<br />’;
echo ‘empty($nothere): ‘.empty($nothere).’<br />’;
והנה הHTML
<form action=”processorder.php” method=”post”>
<table border=”0”>
<tr bgcolor=”#cccccc”>
<td width=”150”>Item</td>
<td width=”15”>Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align=”center”><input type=”text” name=”tireqty” size=”3”
maxlength=”3” /></td>
</tr>
<tr>
<td>Oil</td>
<td align=”center”><input type=”text” name=”oilqty” size=”3”
maxlength=”3” /></td>
</tr><tr>
<td>Spark Plugs</td>
<td align=”center”><input type=”text” name=”sparkqty” size=”3”
maxlength=”3” /></td>
</tr>
<tr>
<td colspan=”2” align=”center”><input type=”submit” value=”Submit Order” /></td>
</tr>
</table>
</form>
<table border=”0”>
<tr bgcolor=”#cccccc”>
<td width=”150”>Item</td>
<td width=”15”>Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align=”center”><input type=”text” name=”tireqty” size=”3”
maxlength=”3” /></td>
</tr>
<tr>
<td>Oil</td>
<td align=”center”><input type=”text” name=”oilqty” size=”3”
maxlength=”3” /></td>
</tr><tr>
<td>Spark Plugs</td>
<td align=”center”><input type=”text” name=”sparkqty” size=”3”
maxlength=”3” /></td>
</tr>
<tr>
<td colspan=”2” align=”center”><input type=”submit” value=”Submit Order” /></td>
</tr>
</table>
</form>
6 תשובות
יש לי טבלה עם פורם, עכשיו זה מין כמו רשימת קניות(כמובן שלא אמיתית) אלא דמו ורק מראה לך כמה כסף תוציא אם תקנה, כמה וכמה דברים..עכשיו כדאי שכנראה ישימו 0 במשהו, אז הוא לא 0 ככה וככה, אלא לא ירשום כלום.